package org.keyroy.app.puzzle_rpg.models;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Tile implements Cloneable {
	public int ID;
	public int resource;

	private Bitmap bitmap;

	private int tx, ty;
	public int cx, cy;

	public void setResource(int color) {
		resource = color;
	}

	public Bitmap getBitmap(Context context) {
		if (bitmap == null) {
			bitmap = BitmapFactory.decodeResource(context.getResources(), resource);
		}
		return bitmap;
	}

	public void initLocation(Map map, int columnIndex, int rowIndex) {
		tx = columnIndex * map.gridWidth;
		ty = rowIndex * map.gridHeight;
	}
	
	public final int  getTX(){
		return tx;
	}
	
	public final int  getTY(){
		return ty;
	}



	public Tile getCopy() {
		try {
			return (Tile) clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}

		return null;
	}
}
